# coding=utf-8

def getCityLevel(cityName):
    import openpyxl
    wb = openpyxl.load_workbook('D:\GYL\群\风控\云业贷A产品评分卡（0821）(1).xlsx')
    sheets = wb.sheetnames
    ws = wb.active
    row_range = ws['A':'F']
    for row in row_range: # 打印 2-5行中所有单元格中的值
        cityLevel = row[0].value
        for cell in row:
            if cell.value != None and cell.value != cityLevel:
                cellValue = cell.value
                if cityName in cellValue:
                    # print(cityLevel)
                    return cityLevel


import json

text_new = ''
with open("city.json","r",encoding='UTF-8') as f:
    text_new = f.read()
# print(text_new)
pp = json.loads(text_new)
provinces = pp['86']
for province in provinces:
    # print(province)
    # print(provinces[province])
     citys = pp[province]
     for city in citys:
        # print(city)
        # print(citys[city])
        ffff = citys[city]
        if '市辖区' in citys[city]:
            ffff = provinces[province]
        cityLevel = getCityLevel(ffff)
        if cityLevel == None:
            cityLevel = ''
        print("CITY_MAP.put(\""+city+"\", new City(\"" + city + "\", \"" + citys[city] + "\", \"" + province + "\", \"" + provinces[province] + "\", \"" + cityLevel + "\"));")

